package com.example.demo.study.designmode.creational.builder;

public class Burger {
    private boolean cheese,lettuce,sauce;

    static class Builder{
        private boolean cheese,lettuce,sauce;
        Builder addCheese(boolean cheese){
            this.cheese = cheese;
            return this;
        }
        Builder addLettuce(boolean lettuce){
            this.lettuce = lettuce;
            return this;
        }
        Builder addSauce(boolean sauce){
            this.sauce = sauce;
            return this;
        }
        Burger build(){
            Burger burger = new Burger();
            burger.cheese = cheese;
            burger.lettuce = lettuce;
            burger.sauce = sauce;
            return burger;
        }
    }

    public void show(){
        System.out.println("cheese: " + cheese + " lettuce: " + lettuce + " sauce: " + sauce);
    }

    public static void main(String[] args) {
        Burger burger1 = new Burger.Builder()
                            .build();
        burger1.show();
        Burger burger2 = new Burger.Builder()
                            .addCheese(true)
                            .addLettuce(true)
                            .addSauce(true).build();
        burger2.show();
        Burger burger3 = new Burger.Builder()
                            .addCheese(true).build();
        burger3.show();
    }
}
